package com.chenyaowei.web.controller.member;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.chenyaowei.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chenyaowei.common.annotation.Log;
import com.chenyaowei.common.core.controller.BaseController;
import com.chenyaowei.common.core.domain.AjaxResult;
import com.chenyaowei.common.enums.BusinessType;
import com.chenyaowei.member.domain.CywIntegrationChangeHistory;
import com.chenyaowei.member.service.ICywIntegrationChangeHistoryService;
import com.chenyaowei.common.utils.poi.ExcelUtil;
import com.chenyaowei.common.core.page.TableDataInfo;

/**
 * 积分变化历史记录Controller
 *
 * @author 陈耀威
 * @date 2023-11-28
 */
@RestController
@RequestMapping("/member/integrationChangeHistory")
public class CywIntegrationChangeHistoryController extends BaseController
{
    @Autowired
    private ICywIntegrationChangeHistoryService cywIntegrationChangeHistoryService;

    /**
     * 查询积分变化历史记录列表
     */
    @Anonymous
    @GetMapping("/list/currentUser")
    public TableDataInfo listByMemberId(CywIntegrationChangeHistory cywIntegrationChangeHistory)
    {
        startPage();
        cywIntegrationChangeHistory.setMemberId(getUserId());
        List<CywIntegrationChangeHistory> list = cywIntegrationChangeHistoryService.selectCywIntegrationChangeHistoryList(cywIntegrationChangeHistory);
        return getDataTable(list);
    }

    /**
     * 查询积分变化历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('member:integrationChangeHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(CywIntegrationChangeHistory cywIntegrationChangeHistory)
    {
        startPage();
        List<CywIntegrationChangeHistory> list = cywIntegrationChangeHistoryService.selectCywIntegrationChangeHistoryList(cywIntegrationChangeHistory);
        return getDataTable(list);
    }

    /**
     * 导出积分变化历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('member:integrationChangeHistory:export')")
    @Log(title = "积分变化历史记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CywIntegrationChangeHistory cywIntegrationChangeHistory)
    {
        List<CywIntegrationChangeHistory> list = cywIntegrationChangeHistoryService.selectCywIntegrationChangeHistoryList(cywIntegrationChangeHistory);
        ExcelUtil<CywIntegrationChangeHistory> util = new ExcelUtil<CywIntegrationChangeHistory>(CywIntegrationChangeHistory.class);
        util.exportExcel(response, list, "积分变化历史记录数据");
    }

    /**
     * 获取积分变化历史记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:integrationChangeHistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cywIntegrationChangeHistoryService.selectCywIntegrationChangeHistoryById(id));
    }

    /**
     * 新增积分变化历史记录
     */
    @PreAuthorize("@ss.hasPermi('member:integrationChangeHistory:add')")
    @Log(title = "积分变化历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CywIntegrationChangeHistory cywIntegrationChangeHistory)
    {
        return toAjax(cywIntegrationChangeHistoryService.insertCywIntegrationChangeHistory(cywIntegrationChangeHistory));
    }

    /**
     * 修改积分变化历史记录
     */
    @PreAuthorize("@ss.hasPermi('member:integrationChangeHistory:edit')")
    @Log(title = "积分变化历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CywIntegrationChangeHistory cywIntegrationChangeHistory)
    {
        return toAjax(cywIntegrationChangeHistoryService.updateCywIntegrationChangeHistory(cywIntegrationChangeHistory));
    }

    /**
     * 删除积分变化历史记录
     */
    @PreAuthorize("@ss.hasPermi('member:integrationChangeHistory:remove')")
    @Log(title = "积分变化历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cywIntegrationChangeHistoryService.deleteCywIntegrationChangeHistoryByIds(ids));
    }
}
